﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 飞机大战
{
    internal class Background : Game
    {
        public Background(int x, int y, int width, int height, Image[] images, int speed, State state)
                        : base(x, y, width, height, images, speed, state)
        { 
            X = x;
            Y = y;
            Width = width;
            Height = height;
            Images = images;
            Speed = speed;
            State = state;
        }

        //画游戏页面
        public override void Draw(Graphics g)
        {
            g.DrawImage(Images[0], this.X, this.Y, Width, Height);

            switch (this.State)
            {
                case State.NoGameStarted:
                    g.DrawImage(Images[1], (this.Width - 240) / 2, this.Height * 0.10f);
                    g.DrawImage(Images[2], (this.Width - 71) / 2, this.Height * 0.40f);
                    g.DrawImage(Images[3], (this.Width - 37) / 2, this.Height * 0.74f);
                    g.DrawString("单击鼠标开始游戏", new Font(new FontFamily("楷体"), 20), new SolidBrush(Color.DeepSkyBlue),
                                  this.Width * 0.37f, this.Height * 0.81f);
                    break;

                case State.GameStarted:
                    if(this.Y >= 0)
                    {
                        this.Y = -this.Height / 2;
                    }
                    this.Y += Speed;
                    break;
            }
        }
    }
}
